package com.xiyoo.cw.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description
 * @Author xiYoo
 * @Date 2024/6/18 11:28
 * @Version 1.0
 **/
@Configuration
public class FilterConfiguration {

    @Bean
    public FilterRegistrationBean logFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        //注入过滤器
        registration.setFilter(new ThreadLogFilter());
        //拦截规则
        registration.addUrlPatterns("/*");
        //过滤器名称
        registration.setName("threadLogFilter");
        //过滤器顺序
        registration.setOrder(0);
        return registration;
    }
}
